package com.dididoctor.patient.Activity.Usercentre.Record.Cases;

import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.view.View;
import android.widget.TextView;

import com.dididoctor.patient.Activity.Usercentre.Record.Cases.CasesDetail.CasesDetailActivity;
import com.dididoctor.patient.Activity.Usercentre.Record.Cases.CasesDetailUp.CasesDetailUpActivity;
import com.dididoctor.patient.MV.adapter.CommonAdapter;
import com.dididoctor.patient.MV.adapter.ViewHolder;
import com.dididoctor.patient.R;

import java.util.List;

/**
 * Created by Administrator on 2016/4/15.
 */
public class CasesAdapter extends CommonAdapter<CasesBean> {
    private TextView mTvHostipal, mTvDate, mTvName, mTvType, mTvBing;
    private Context context;

    public CasesAdapter(Context context, List<CasesBean> datas) {
        super(context, datas, R.layout.item_case);
        this.context = context;
    }

    @Override
    public void convert(int position, ViewHolder helper, final CasesBean item) {
        mTvHostipal = helper.getView(R.id.tv_hospital);
        mTvDate = helper.getView(R.id.tv_date);
        mTvName = helper.getView(R.id.tv_doctorname);
        mTvType = helper.getView(R.id.tv_type);
        mTvBing = helper.getView(R.id.tv_jibing);
        helper.getView(R.id.img_look_detail).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if ("2".equals(item.getType())) {//自传
                    Intent intent = new Intent(context, CasesDetailUpActivity.class);
                    intent.putExtra("recId", item.getRecId());
                    context.startActivity(intent);
                } else {//医生
                    Intent intent = new Intent(context, CasesDetailActivity.class);
                    intent.putExtra("recId", item.getRecId());
                    intent.putExtra("type", item.getType());
                    context.startActivity(intent);
                }

            }
        });
        mTvHostipal.setText(item.getHosName());
        mTvDate.setText(item.getClinicDate());
        mTvName.setText(item.getDctName());
        if ("2".equals(item.getType())) {//自传
            mTvType.setText("自传");
            mTvType.setTextColor(Color.parseColor("#43b2ff"));
            mTvType.setBackground(context.getResources().getDrawable(R.drawable.bg_doctor_label_blue));
        } else {
            mTvType.setText("医生");
            mTvType.setTextColor(Color.parseColor("#fc8713"));
            mTvType.setBackground(context.getResources().getDrawable(R.drawable.bg_doctor_label_yellow));
        }
        mTvBing.setText(item.getDescr());
    }
}
